package com.neusoft.neuiotms.dcam.workflow.converter;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import com.neusoft.bizcore.web.dto.AbstractConverter;
import com.neusoft.neuiotms.dcam.workflow.dto.RukuFinanceAssetSLDTO;
import com.neusoft.neuiotms.dcam.workflow.model.RukuFinanceConfirmAssetSL;
import com.neusoft.neuiotms.dcam.workflow.repository.RukuFinanceAssetConfirmSLRepository;

@Component
public class RukuFinanceAssetConfirmSLConverter
        extends AbstractConverter<RukuFinanceConfirmAssetSL, RukuFinanceAssetSLDTO> {

    @Autowired
    private RukuFinanceAssetConfirmSLRepository rukuFinanceAssetConfirmSLRepository;

    @Override
    public RukuFinanceConfirmAssetSL toModel(final RukuFinanceAssetSLDTO dto) {
        RukuFinanceConfirmAssetSL model = null;
        if (dto.isNew()) {
            model = new RukuFinanceConfirmAssetSL();
        } else {
            model = this.rukuFinanceAssetConfirmSLRepository.getOne(dto.getId());
        }

        model.setName(dto.getName());
        model.setBrand(dto.getBrand());
        model.setSpecifications(dto.getSpecifications());
        model.setSerialnumber(dto.getSerialnumber());
        model.setPurchaseDate(dto.getPurchaseDate());
        model.setMaintenanceStartTime(dto.getMaintenanceStartTime());
        model.setMaintenanceEndTime(dto.getMaintenanceEndTime());
        model.setBigTypeName(dto.getBigTypeName());
        model.setBigTypeCode(dto.getBigTypeCode());
        model.setMiddleTypeName(dto.getMiddleTypeName());
        model.setMiddleTypeCode(dto.getMiddleTypeCode());
        model.setSmallTypeName(dto.getSmallTypeName());
        model.setSmallTypeCode(dto.getSmallTypeCode());
        model.setMeasureUnit(dto.getMeasureUnit());
        model.setAmount(dto.getAmount());
        model.setUsePeriod(dto.getUsePeriod());
        model.setCard(dto.getCard());
        model.setNote(dto.getNote());
        model.setManagementOrgCode(dto.getManagementOrgCode());
        model.setManagementOrgName(dto.getManagementOrgName());
        model.setManagementUserCode(dto.getManagementUserCode());
        model.setManagementUserName(dto.getManagementUserName());
        model.setMoney(dto.getMoney());
        model.setPurpose(dto.getPurpose());
        return model;
    }

    @Override
    public RukuFinanceAssetSLDTO toDTO(final RukuFinanceConfirmAssetSL model, final boolean forListView) {
        final RukuFinanceAssetSLDTO dto = new RukuFinanceAssetSLDTO();

        dto.setId(model.getId());
        dto.setName(model.getName());
        dto.setBrand(model.getBrand());
        dto.setSpecifications(model.getSpecifications());
        dto.setSerialnumber(model.getSerialnumber());
        dto.setPurchaseDate(model.getPurchaseDate());
        dto.setMaintenanceStartTime(model.getMaintenanceStartTime());
        dto.setMaintenanceEndTime(model.getMaintenanceEndTime());
        dto.setBigTypeName(model.getBigTypeName());
        dto.setBigTypeCode(model.getBigTypeCode());
        dto.setMiddleTypeName(model.getMiddleTypeName());
        dto.setMiddleTypeCode(model.getMiddleTypeCode());
        dto.setSmallTypeName(model.getSmallTypeName());
        dto.setSmallTypeCode(model.getSmallTypeCode());
        dto.setMeasureUnit(model.getMeasureUnit());
        dto.setAmount(model.getAmount());
        dto.setUsePeriod(model.getUsePeriod());
        dto.setCard(model.getCard());
        dto.setNote(model.getNote());
        dto.setManagementOrgCode(model.getManagementOrgCode());
        dto.setManagementOrgName(model.getManagementOrgName());
        dto.setManagementUserCode(model.getManagementUserCode());
        dto.setManagementUserName(model.getManagementUserName());
        dto.setMoney(model.getMoney());
        dto.setPurpose(model.getPurpose());
        return dto;
    }

    public void clone(final RukuFinanceConfirmAssetSL model, final RukuFinanceAssetSLDTO dto) {
        model.setName(dto.getName());
        model.setBrand(dto.getBrand());
        model.setSpecifications(dto.getSpecifications());
        model.setSerialnumber(dto.getSerialnumber());
        model.setPurchaseDate(dto.getPurchaseDate());
        model.setMaintenanceStartTime(dto.getMaintenanceStartTime());
        model.setMaintenanceEndTime(dto.getMaintenanceEndTime());
        model.setBigTypeName(dto.getBigTypeName());
        model.setBigTypeCode(dto.getBigTypeCode());
        model.setMiddleTypeName(dto.getMiddleTypeName());
        model.setMiddleTypeCode(dto.getMiddleTypeCode());
        model.setSmallTypeName(dto.getSmallTypeName());
        model.setSmallTypeCode(dto.getSmallTypeCode());
        model.setMeasureUnit(dto.getMeasureUnit());
        model.setAmount(dto.getAmount());
        model.setUsePeriod(dto.getUsePeriod());
        model.setCard(dto.getCard());
        model.setNote(dto.getNote());
        model.setManagementOrgCode(dto.getManagementOrgCode());
        model.setManagementOrgName(dto.getManagementOrgName());
        model.setManagementUserCode(dto.getManagementUserCode());
        model.setManagementUserName(dto.getManagementUserName());
        model.setMoney(dto.getMoney());
        model.setPurpose(dto.getPurpose());
    }

}
